<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入添加的数量">
<input type="button" value="帅哥" onclick="f(1)">
<input type="button" value="美女" onclick="f(2)">
<hr>
<script>
    let input = document.querySelector("input");
    function f(x) {
        let imgURL= x==1?"a.jpg":"b.jpg";
        for (let i = 0; i < input.value; i++) {
            //创建图片标签
            let img = document.createElement("img");
            //设置图片路径
            img.src = imgURL;
            //添加到页面中
            document.body.append(img);
        }

    }
</script>


</body>
</html>